# -*- coding: utf-8 -*-

 ###############################################
 ##                                             ##
 ##   config                                     ##
 ##                                              ##
 ##                                              ##
 ##   for Taller Básico                          ##
 ##   by Críptidos Digitales                     ##
 ##   GPL (c)2005                                ##
  ##                                             ##
    ###############################################

from utilities import ConfigParser


class Parser(ConfigParser):

    def __init__(self):
        ConfigParser.__init__(self)
        try:
            self.init()
        except:
            pass


    def init(self):
        self.pushSection('layout', {
            "pos_x":  '100',
            "pos_y":  '100',
            "size_x": '640',
            "size_y": '480',
            "sash_pos": '200',
            "xPos_access": '100',
            "yPos_access": '100',
            "xSize_access":'-1',
            "ySize_access":'-1'
            })
        self.pushSection('properties', {
            "server":    'localhost',
            "dialect":   'postgresql',
            "database":  '',
            "user":      '',
            "ubicacion": '/',
            "logginglevel": 'debug',
            "sessiontype":  'debug'
            })
        self.pushSection('format', {
            "factura":  'factura.txt',
            "remision": 'remision.txt'
            })

        ## if not self.pull('properties', "loggingeffectivelevel"):
            ## self.push('properties', "loggingeffectivelevel", 'debug')

            # "database":  'sqlite:///ebt.db',

import logging
logger = logging.getLogger( 'logger' )
if not logger.handlers :
    hdlr = logging.FileHandler( "logger.log" )
    hdlr.setFormatter( logging.Formatter( '%(asctime)s %(levelname)s %(message)s' ) )
    logger.addHandler( hdlr )

## config = Parser()         # Para checar que el archivo .cfg está bien

## level = config.pull( 'properties', 'loggingLevel', 'warning' )
## logger.setLevel( eval( "logging." + level.upper( ) ) )

